package com.gz.logistics.library.pojo;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 订单详情
 * author wanner1991
 */
public class SumOfMoney implements Serializable{
    private String total_money;//应收总金额
    private String real_total_money;//实收总金额
    private List<Money> money;

    public List<Money> getMoney() {
        return money;
    }

    public void setMoney(List<Money> money) {
        this.money = money;
    }

    public String getTotal_money() {
        return total_money;
    }

    public void setTotal_money(String total_money) {
        this.total_money = total_money;
    }

    public String getReal_total_money() {
        return real_total_money;
    }

    public void setReal_total_money(String real_total_money) {
        this.real_total_money = real_total_money;
    }


    public static List<SumOfMoney> parse(JSONArray jsonArray) throws JSONException {
        if (jsonArray == null || jsonArray.length() <= 0){
            return null;
        }
        List<SumOfMoney> moneyinfos = new ArrayList<SumOfMoney>();
        for (int i = 0 ; i < jsonArray.length() ; i++ ){
            SumOfMoney info = new SumOfMoney();
            JSONObject object = jsonArray.getJSONObject(i);
            info.total_money = object.getString("total_money");
            info.real_total_money = object.getString("real_total_money");
            info.money = Money.parse(object.getJSONArray("money"));
            moneyinfos.add(info);
        }
        return moneyinfos;
    }

    public static SumOfMoney parse(JSONObject object) throws JSONException {
        if (object == null){
            return null;
        }
        SumOfMoney info = new SumOfMoney();
        info.total_money = object.getString("total_money");
        info.real_total_money = object.getString("total_real_money");
        info.money = Money.parse(object.getJSONArray("money"));

        return info;

    }
}
